package com.example.shardingsphere.config.shard;

import org.apache.shardingsphere.infra.config.algorithm.ShardingSphereAlgorithmConfiguration;

import java.util.Properties;

public class ShardTableCustomCreateDateRuleConfig {

    /**
     * 表分片算法配置
     * 自定义分表规则
     *
     * @return
     */
    public static ShardingSphereAlgorithmConfiguration shardTableAlgorithmsPros() {

        // 配置分表算法
        Properties tableShardingAlgorithmProps = new Properties();

        tableShardingAlgorithmProps.setProperty("strategy", "STANDARD");
        // 自定义规则实现类
        tableShardingAlgorithmProps.setProperty("algorithmClassName", "com.example.shardingsphere.rule.CustomTableCreateDateRule");
        // CLASS_BASED 自定义规则类型
        return new ShardingSphereAlgorithmConfiguration("CLASS_BASED", tableShardingAlgorithmProps);
    }
}
